var express = require('express');
var router = express.Router();

/* GET home page. */
const {addClaims, getClaims, getClaimsByCustomer, getClaimsBySalesMen, getClaimsById, changeClaims, getClaimsByState, deleteClaims, searchClaims} = require('../service/claimsService')
//添加理赔信息
router.post('/addClaims', async (req, res) => {
  const data = await addClaims(req.body);
  res.send(data)
})

//获取所有理赔信息
router.post('/getClaims', async (req, res) => {
  console.log(req.body);
  const data = await getClaims(req.body);
  res.send(data)
})

//根据state获取
router.post('/getClaimsByState', async (req, res) => {
  const data = await getClaimsByState(req.body);
  res.send(data)
})

//根据客户id获取理赔信息   参数： 客户的_id
router.get('/getClaimsByCustomer', async (req, res) => {
  const data = await getClaimsByCustomer(req.body);
  res.send(data)
})

//根据销售员id获取理赔信息   参数： 销售员的_id
router.post('/getClaimsBySalesMen', async (req, res) => {
  const data = await getClaimsBySalesMen(req.body);
  res.send(data)
})


//根据审核订单id获取
router.post('/getClaimsById', async (req, res) => {
  const data = await getClaimsById(req.body)
  res.send(data);
})
//修改理赔订单
router.post('/changeClaims', async (req, res) => {
  const data = await changeClaims(req.body);
  res.send(data);
})
//删除
router.post('/deleteClaims', async(req, res) => {
  const data = await deleteClaims(req.body);
  res.send(data)
})

//查询
router.post('/searchClaims', async(req, res) => {
  const data = await searchClaims(req.body);
  res.send(data)
})


module.exports = router;